home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / EditorPanMachine.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  8.8 KB  |  280 lines

  1. class EditorPanMachine extends Library.State
  2. {
  3.    var oCenterMachine;
  4.    var mcRef;
  5.    static var DEPTH_VISUAL = 150;
  6.    static var DEPTH_NUMBER = 450;
  7.    static var RECURSIVE_LEVEL_SEARCH = 5;
  8.    static var SCALE_PERCENT = 30;
  9.    static var VISUAL_IN_BOX_X = -225;
  10.    static var VISUAL_IN_BOX_Y = -60;
  11.    function EditorPanMachine(__mcRef)
  12.    {
  13.       super(__mcRef);
  14.       this.oCenterMachine = new EditorCenterPanMachine(this.mcRef.mcState.mcCenter,this);
  15.       this.oCenterMachine.setNumber(1);
  16.       this.oCenterMachine.setRef(this.mcRef.mcState.mcCenter);
  17.       Main.Instance.doAddListener(this);
  18.       this.setState("Idle");
  19.    }
  20.    function doScrollToLeft()
  21.    {
  22.       this.setState("ToLeft");
  23.    }
  24.    function doScrollToRight()
  25.    {
  26.       this.setState("ToRight");
  27.    }
  28.    function setVisualForBox(__sLinkage, __mcBox)
  29.    {
  30.       __mcBox.mcNumber.swapDepths(EditorPanMachine.DEPTH_NUMBER);
  31.       __mcBox.mcData.mcVisual.removeMovieClip();
  32.       __mcBox.mcData.attachMovie(__sLinkage,"mcVisual",EditorPanMachine.DEPTH_VISUAL);
  33.       __mcBox.mcData.mcVisual.gotoAndStop(__mcBox.mcData.mcVisual._totalframes);
  34.       __mcBox.mcData.mcVisual._xscale = EditorPanMachine.SCALE_PERCENT;
  35.       __mcBox.mcData.mcVisual._yscale = EditorPanMachine.SCALE_PERCENT;
  36.       __mcBox.mcData.mcVisual._x = EditorPanMachine.VISUAL_IN_BOX_X;
  37.       __mcBox.mcData.mcVisual._y = EditorPanMachine.VISUAL_IN_BOX_Y;
  38.       this.doRecursiveWorkOn(__mcBox.mcData.mcVisual,EditorPanMachine.RECURSIVE_LEVEL_SEARCH);
  39.    }
  40.    function doRecursiveWorkOn(__mc, __nRecursive)
  41.    {
  42.       if(__mc instanceof MovieClip)
  43.       {
  44.          __mc.stop();
  45.          if(__mc._name.indexOf("Hit") != -1)
  46.          {
  47.             __mc._visible = false;
  48.          }
  49.          else if(__mc._name.indexOf("Ground") != -1)
  50.          {
  51.             __mc._visible = false;
  52.          }
  53.       }
  54.       if(__nRecursive > 0)
  55.       {
  56.          for(var _loc4_ in __mc)
  57.          {
  58.             this.doRecursiveWorkOn(__mc[_loc4_],__nRecursive);
  59.          }
  60.          __nRecursive = __nRecursive - 1;
  61.       }
  62.    }
  63.    function doRefreshVisual()
  64.    {
  65.       this.oCenterMachine.doRefreshVisual();
  66.       this.doLoadStateAction();
  67.    }
  68.    function doDestroy()
  69.    {
  70.       Main.Instance.doRemoveListener(this);
  71.    }
  72.    function get CenterMachine()
  73.    {
  74.       return this.oCenterMachine;
  75.    }
  76.    function doToLeft()
  77.    {
  78.       if(this.isStateComplete())
  79.       {
  80.          this.setState("Idle");
  81.       }
  82.    }
  83.    function doToRight()
  84.    {
  85.       if(this.isStateComplete())
  86.       {
  87.          this.setState("Idle");
  88.       }
  89.    }
  90.    function doLoadStateAction()
  91.    {
  92.       super.doLoadStateAction();
  93.       this.oCenterMachine.setRef(this.mcRef.mcState.mcCenter);
  94.       switch(this.CurrentState)
  95.       {
  96.          case "ToLeft":
  97.             this.doSetUpLeft();
  98.             break;
  99.          case "ToRight":
  100.             this.doSetUpRight();
  101.             break;
  102.          case "Idle":
  103.             this.doSetUpIdle();
  104.             LevelEditor.Instance.onMoveStop();
  105.       }
  106.    }
  107.    function doSetUpLeft()
  108.    {
  109.       var _loc3_ = LevelEditor.Instance.CurrentPanelNumber;
  110.       var _loc9_ = _loc3_ - 1;
  111.       if(_loc9_ <= 0)
  112.       {
  113.          _loc9_ = LevelEditor.PANELS_QTY;
  114.       }
  115.       var _loc10_ = LevelEditor.Instance.getLinkageFor(_loc3_);
  116.       var _loc13_ = LevelEditor.Instance.getLinkageFor(_loc9_);
  117.       var _loc4_ = LevelEditor.Instance.getNumberForPanel(_loc10_);
  118.       var _loc8_ = LevelEditor.Instance.getNumberForPanel(_loc13_);
  119.       if(_loc4_ > LevelEditor.LETTERS.length - 1)
  120.       {
  121.          _loc4_ = 0;
  122.       }
  123.       else if(_loc4_ < 0)
  124.       {
  125.          _loc4_ = LevelEditor.LETTERS.length - 1;
  126.       }
  127.       if(_loc8_ > LevelEditor.LETTERS.length - 1)
  128.       {
  129.          _loc8_ = 0;
  130.       }
  131.       else if(_loc8_ < 0)
  132.       {
  133.          _loc8_ = LevelEditor.LETTERS.length - 1;
  134.       }
  135.       var _loc11_ = LevelEditor.LETTERS[_loc4_];
  136.       var _loc12_ = LevelEditor.LETTERS[_loc8_];
  137.       this.mcRef.mcState.mcBoxRight.mcNumber.txtNumber.text = _loc11_;
  138.       var _loc6_ = LevelEditor.Instance.getLinkageFor(_loc3_);
  139.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxRight);
  140.       var _loc7_ = _loc3_ - 2;
  141.       if(_loc7_ > LevelEditor.PANELS_QTY)
  142.       {
  143.          _loc7_ = 1;
  144.       }
  145.       else if(_loc7_ < 0)
  146.       {
  147.          _loc7_ = LevelEditor.PANELS_QTY;
  148.       }
  149.       this.mcRef.mcState.mcBoxLeft._visible = true;
  150.       this.mcRef.mcState.mcBoxLeft.mcNumber.txtNumber.text = _loc12_;
  151.       _loc6_ = LevelEditor.Instance.getLinkageFor(_loc7_);
  152.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxLeft);
  153.       var _loc5_ = _loc3_ - 1;
  154.       if(_loc5_ > LevelEditor.PANELS_QTY)
  155.       {
  156.          _loc5_ = 1;
  157.       }
  158.       else if(_loc5_ <= 0)
  159.       {
  160.          _loc5_ = LevelEditor.PANELS_QTY;
  161.       }
  162.       this.oCenterMachine.setNumber(_loc5_);
  163.       var _loc2_ = _loc3_ + 1;
  164.       if(_loc2_ > LevelEditor.PANELS_QTY)
  165.       {
  166.          _loc2_ = 1;
  167.       }
  168.       else if(_loc2_ < 0)
  169.       {
  170.          _loc2_ = LevelEditor.PANELS_QTY;
  171.       }
  172.       this.mcRef.mcState.mcBoxRightAbs._visible = true;
  173.       this.mcRef.mcState.mcBoxRightAbs.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc2_,2);
  174.       _loc6_ = LevelEditor.Instance.getLinkageFor(_loc2_);
  175.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxRightAbs);
  176.    }
  177.    function doSetUpRight()
  178.    {
  179.       var _loc2_ = LevelEditor.Instance.CurrentPanelNumber;
  180.       var _loc9_ = LevelEditor.Instance.getLinkageFor(_loc2_ + 1);
  181.       var _loc12_ = LevelEditor.Instance.getLinkageFor(_loc2_);
  182.       var _loc4_ = LevelEditor.Instance.getNumberForPanel(_loc9_);
  183.       var _loc7_ = LevelEditor.Instance.getNumberForPanel(_loc12_);
  184.       if(_loc4_ > LevelEditor.LETTERS.length - 1)
  185.       {
  186.          _loc4_ = 0;
  187.       }
  188.       else if(_loc4_ < 0)
  189.       {
  190.          _loc4_ = LevelEditor.LETTERS.length - 1;
  191.       }
  192.       if(_loc7_ > LevelEditor.LETTERS.length - 1)
  193.       {
  194.          _loc7_ = 0;
  195.       }
  196.       else if(_loc7_ < 0)
  197.       {
  198.          _loc7_ = LevelEditor.LETTERS.length - 1;
  199.       }
  200.       var _loc10_ = LevelEditor.LETTERS[_loc4_];
  201.       var _loc11_ = LevelEditor.LETTERS[_loc7_];
  202.       this.mcRef.mcState.mcBoxLeft.mcNumber.txtNumber.text = _loc11_;
  203.       var _loc6_ = LevelEditor.Instance.getLinkageFor(_loc2_);
  204.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxLeft);
  205.       var _loc8_ = _loc2_ + 2;
  206.       if(_loc8_ > LevelEditor.PANELS_QTY)
  207.       {
  208.          _loc8_ = 1;
  209.       }
  210.       else if(_loc8_ < 0)
  211.       {
  212.          _loc8_ = LevelEditor.PANELS_QTY;
  213.       }
  214.       this.mcRef.mcState.mcBoxRight._visible = true;
  215.       this.mcRef.mcState.mcBoxRight.mcNumber.txtNumber.text = _loc10_;
  216.       _loc6_ = LevelEditor.Instance.getLinkageFor(_loc8_);
  217.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxRight);
  218.       var _loc5_ = _loc2_ + 1;
  219.       if(_loc5_ > LevelEditor.PANELS_QTY)
  220.       {
  221.          _loc5_ = 1;
  222.       }
  223.       else if(_loc5_ < 0)
  224.       {
  225.          _loc5_ = LevelEditor.PANELS_QTY;
  226.       }
  227.       this.oCenterMachine.setNumber(_loc5_);
  228.       var _loc3_ = _loc2_ - 1;
  229.       if(_loc3_ > LevelEditor.PANELS_QTY)
  230.       {
  231.          _loc3_ = 1;
  232.       }
  233.       else if(_loc3_ < 0)
  234.       {
  235.          _loc3_ = LevelEditor.PANELS_QTY;
  236.       }
  237.       this.mcRef.mcState.mcBoxLeftAbs._visible = true;
  238.       this.mcRef.mcState.mcBoxLeftAbs.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc3_,2);
  239.       _loc6_ = LevelEditor.Instance.getLinkageFor(_loc3_);
  240.       this.setVisualForBox(_loc6_,this.mcRef.mcState.mcBoxLeftAbs);
  241.    }
  242.    function doSetUpIdle()
  243.    {
  244.       var _loc2_ = LevelEditor.Instance.CurrentPanelNumber;
  245.       if(_loc2_ > 1)
  246.       {
  247.          this.mcRef.mcState.mcBoxLeft._visible = true;
  248.          this.mcRef.mcState.mcBoxLeft.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc2_ - 1,2);
  249.          var _loc4_ = LevelEditor.Instance.getLinkageFor(_loc2_ - 1);
  250.          this.setVisualForBox(_loc4_,this.mcRef.mcState.mcBoxLeft);
  251.       }
  252.       else
  253.       {
  254.          this.mcRef.mcState.mcBoxLeft._visible = false;
  255.       }
  256.       var _loc3_ = _loc2_;
  257.       if(_loc3_ > LevelEditor.PANELS_QTY)
  258.       {
  259.          _loc3_ = 1;
  260.       }
  261.       else if(_loc3_ < 0)
  262.       {
  263.          _loc3_ = LevelEditor.PANELS_QTY;
  264.       }
  265.       this.oCenterMachine.setNumber(_loc3_);
  266.       if(_loc2_ > LevelEditor.PANELS_QTY)
  267.       {
  268.          _loc2_ = 1;
  269.       }
  270.       else if(_loc2_ < 0)
  271.       {
  272.          _loc2_ = LevelEditor.PANELS_QTY;
  273.       }
  274.       this.mcRef.mcState.mcBoxRight._visible = true;
  275.       this.mcRef.mcState.mcBoxRight.mcNumber.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc2_ + 1,2);
  276.       _loc4_ = LevelEditor.Instance.getLinkageFor(_loc2_ + 1);
  277.       this.setVisualForBox(_loc4_,this.mcRef.mcState.mcBoxRight);
  278.    }
  279. }
  280.